package argo.review;

/**
 * 多数元素
 */
public class MajorityElement {

    public int majorityElement(int[] nums) {
        int condidate = nums[0], count = 0;
        for (int num : nums) {
            if (count == 0) {
                condidate = num;
            }
            if (num == condidate) {
                count--;
            } else {
                count++;
            }
        }
        return condidate;
    }
}
